package main

import (
	"encoding/json"
	"fmt"
)

type Monster struct {
	Name string
	Age int
	Birthday string
	Sal float64
	Skill string
}

func testStruct() {

	// 演示
	monster := Monster {
		Name: "丁佑强",
		Age: 26,
		Birthday: "1996",
		Sal: 8000.0,
		Skill: "linux",
	}

	// 将monster序列化
	data, err := json.Marshal(&monster)

	if err != nil {
		fmt.Println("err:", err)
		return
	}

	// 输出序列化后的结果
	fmt.Printf("monster序列号化后：%v\n", string(data))


}

func main() {

	// 演示将结构体，map，切片进行序列化
	testStruct()

}